package vo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
 * 主键，订单号，时间，商品信息，收货人，顾客，跟地址表关联的东西，金额，付款方式，订单状态，备注,订单评价,评价等级
 *
 */
@Entity
@Table(name="orderform")
public class OrderForm implements Serializable{

	// 使用序列自增长作为订单的唯一标识
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer orderId;
	
	//订单编号
	private String orderNumber;
	
	//订购时间
	private String orderTime;

	//一个订单对应多个商品条目
	@OneToMany(fetch=FetchType.LAZY,targetEntity=CommodityItem.class,mappedBy="orderform")

	private Set<CommodityItem> commodityitem = new HashSet<CommodityItem>();
	
	//多个订单对应一个顾客

	@ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE})
	@JoinColumn(name ="clientId",nullable=false , updatable=false)
	//@Transient
	private Client cust;
	//多个订单对应一个商家
	@ManyToOne(optional=false,fetch=FetchType.LAZY,targetEntity=Store.class)
	//@Transient
	@JoinColumn(name ="store_order_id",nullable=false , updatable=false)
	private Store store;
	//收货人
	private String receiver;
	
	//收货地址
	private Address orderAddress;
	
	//总价
	private double money;
	
	// 付款方式
	private int payType;// 付款方式：true表示网上付款，false表示到付
	
	private int orderStatus;// 订单状态：0：取消过的订单，1：正常完成的订单，2：未完成的订单
	
	private String evaluation;//订单评价
	
	private String orderTip;// 备注

	private int estate;//评价等级

	
	public int getEstate() {
		return estate;
	}

	public void setEstate(int estate) {
		this.estate = estate;
	}

	public Set<CommodityItem> getCommodityitem() {
		return commodityitem;
	}

	public void setCommodityitem(Set<CommodityItem> commodityitem) {
		this.commodityitem = commodityitem;
	}

	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	public String getEvaluation() {
		return evaluation;
	}

	public void setEvaluation(String evaluation) {
		this.evaluation = evaluation;
	}

	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public String getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(String orderTime) {
		this.orderTime = orderTime;
	}

	/*public Set<Commodity> getCommodity() {
		return commodity;
	}

	public void setCommodity(Set<Commodity> commodity) {
		this.commodity = commodity;
	}
*/
	

	public Client getCust() {
		return cust;
	}

	public void setCust(Client cust) {
		this.cust = cust;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public Address getOrderAddress() {
		return orderAddress;
	}

	public void setOrderAddress(Address orderAddress) {
		this.orderAddress = orderAddress;
	}

	
	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}


	public int getPayType() {
		return payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	public int getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(int orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getOrderTip() {
		return orderTip;
	}

	public void setOrderTip(String orderTip) {
		this.orderTip = orderTip;
	}
	

}
